cmake_minimum_required(VERSION 3.10)

# set(CMAKE_CXX_COMPILER_FORCED "ON")
# set(CMAKE_C_COMPILER_FORCED "ON")
# set(CMAKE_VERBOSE_MAKEFILE "ON")

# 设置项目名和语言
project(VScodeProj LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)

# 添加可执行文件
add_executable(VScodeProj src/main.cpp)

# 让你的目标可以找到 glfw3.h
target_include_directories(VScodeProj PRIVATE src/extern/GLFW/include)
target_include_directories(VScodeProj PRIVATE src/extern/GLEW/include)

# 声明 DLL 导入库（glfw3.dll.a）
add_library(glfw3 SHARED IMPORTED)
set_target_properties(glfw3 PROPERTIES
    IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/src/extern/GLFW/lib-mingw-w64/glfw3.dll"
    IMPORTED_IMPLIB   "${CMAKE_SOURCE_DIR}/src/extern/GLFW/lib-mingw-w64/libglfw3dll.a"
)

# 声明 DLL 导入库（glfw3.dll.a）
add_library(glew SHARED IMPORTED)
set_target_properties(glew PROPERTIES
    IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/src/extern/GLEW/lib/glew32.dll"
    IMPORTED_IMPLIB   "${CMAKE_SOURCE_DIR}/src/extern/GLEW/lib/glew32.lib"
)

target_link_libraries(VScodeProj glew glfw3 opengl32)

add_custom_command(TARGET VScodeProj POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${CMAKE_SOURCE_DIR}/src/extern/GLFW/lib-mingw-w64/glfw3.dll"
        "${CMAKE_SOURCE_DIR}/src/extern/GLEW/lib/glew32.dll"
        $<TARGET_FILE_DIR:VScodeProj>)